<?php

class Home extends admin_controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('member/member_model');
		$this->load->model('person/person_model');
	}
	
	function index()
	{
		$this->breadcrumb = array(
			'Admin panel' =>'',
			'Dashboard' => URL_ADMIN,
		);

		//Get total members
		$total_members = $this->member_model->getListMember(null, null, null);
		$memActive = $this->member_model->getListMember(array('status' => 1), null, null)->num_rows();
		$memUnActive = $this->member_model->getListMember(array('status' => 0), null, null)->num_rows();
		$total_members = $total_members->num_rows();

		//Get 5 newest members
		$newest_members = $this->member_model->getListMember(null, array('id'=>'desc'), array('begin' => 0, 'max' => 5))->result_array();

		// Get 5 new person
		$persons = $this->db->select('id, name, country, state, public')->limit('5')->order_by('id', 'desc')->get('person')->result_array();

		$this->template->title('Welcome to Admin Console', $this->config->item('site_cms'))
				->set(array('total_members' => $total_members, 'memActive' => $memActive, 'memUnActive' => $memUnActive, 'newest_members' => $newest_members, 'persons' => $persons))
			  	->build('admin/admin_home');
	}
	
}